<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core" xmlns:util="http://xmlns.jcp.org/jsf/composite/util">

    <p:dialog header="Administreaza acorduri contract" widgetVar="contract_agrs_WV" dynamic="true" minHeight="300"
              width="900" modal="true">

        <h:form id="contract_agreements_form">
            <util:dataTableWrapper title="Lista acorduri contract">
                <f:facet name="buttonContent">
                    <p:commandButton icon="custom-icon-add" value="Adauga acord contract"
                                     oncomplete="PF('add_contract_agr_WV').show()" update=":create_contract_agr_form"
                                     resetValues="true"
                                     actionListener="#{employmentDataBean.resetCreateContractAgreementDialog}"/>
                </f:facet>
                <p:dataTable id="contract_agreements_table" var="ca" value="#{employmentDataBean.selectedContract.contractAgreementsAsList}"
                             emptyMessage="Nu a fost gasita nici o inregistrare."
                             paginator="true" paginatorPosition="bottom" rowsPerPageTemplate="5,10,15" rows="10"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">

                    <p:column headerText="Numar acord" width="20%">
                        <h:outputText value="#{ca.agreementNumber}"/>
                    </p:column>

                    <p:column headerText="Data acord" width="20%">
                        <h:outputText value="#{ca.agreementDate}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>

                    <p:column headerText="Descriere" width="40%">
                        <h:outputText value="#{ca.description}"/>
                    </p:column>

                    <p:column styleClass="override-icons" headerText="Actions">
                        <p:commandButton icon="custom-icon-edit"
                                         actionListener="#{employmentDataBean.setSelectedContractAgreement(ca)}"
                                         oncomplete="PF('add_contract_agr_WV').show()"
                                         update=":create_contract_agr_form"/>

                        <p:commandButton icon="custom-icon-delete"
                                         actionListener="#{employmentDataBean.deleteContractAgreement(ca)}"
                                         update="@form">
                            <p:confirm header="Confirma"
                                       message="Sunteti sigur ca doriti stergerea acordului selectat?"
                                       icon="ui-icon-alert"/>
                        </p:commandButton>
                    </p:column>
                </p:dataTable>
            </util:dataTableWrapper>
            <p:confirmDialog global="true">
                <p:commandButton value="Da" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
                <p:commandButton value="Nu" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
            </p:confirmDialog>

            <p:outputPanel layout="block" style="border-top: 1px solid #A8A8A8; margin-top: 10px; padding: 5px;">
                <p:commandButton value="Inchide" onclick="PF('contract_agrs_WV').hide();" process="@none"/>
            </p:outputPanel>
        </h:form>
    </p:dialog>


</ui:composition>
